﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<UserControl x:Class="System.Windows.Controls.Samples.AutoCompleteBoxSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:samples="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    >
    <UserControl.Resources>
        <samples:SampleEmployeeCollection x:Key="SampleEmployees" />
    </UserControl.Resources>

    <StackPanel>

        <ContentControl Content="AutoCompleteBox" Style="{StaticResource Header}" />
        <TextBlock Style="{StaticResource Information}">
            AutoCompleteBox is a control that provides suggested items for a 
            TextBox. It can be bound to rich data objects, exposes a 
            SelectedItem property, and is highly customizable and extensible.
            
            <LineBreak /><LineBreak />
            
            The following sections cover key properties and settings that 
            customize the way that AutoCompleteBox behaves.
            <LineBreak />
        </TextBlock>

        <controls:TabControl>
            <controls:TabItem Header="IsTextCompletionEnabled">
                <StackPanel>
                    <TextBlock Style="{StaticResource Information}">
                        IsTextCompletionEnabled will automatically select the 
                        best matching suggestion when one becomes available. The
                        text will be automatically completed for you. 
                        IsTextCompletionEnabled is set to False by default.
                    </TextBlock>

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="230" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Padding="5" Grid.Row="0">Default:</TextBlock>
                        <inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="False" 
                            Width="230" 
                            Grid.Row="0" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value1"
                            SelectionChanged="OnSelectionChanged"
                        />
                        <ContentPresenter Name="Value1" Grid.Row="0" Grid.Column="2" />

                        <TextBlock Padding="5" Grid.Row="1">IsTextCompletionEnabled:</TextBlock>
                        <inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="True"
                            Width="230" 
                            Grid.Row="1" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value2"
                            SelectionChanged="OnSelectionChanged"
                        />
                        <ContentPresenter Grid.Row="1" Name="Value2" Grid.Column="2" />

                    </Grid>
                </StackPanel>
            </controls:TabItem>
            <controls:TabItem Header="FilterMode">
                <StackPanel>
                    <TextBlock Style="{StaticResource Information}">
            FilterMode makes it easy to customize the search filter that is 
            used on the text. The default value is StartsWith: a case-insensitive 
            search filter that compares the start of strings.
            
            <LineBreak /><LineBreak />
            
            Other FilterMode values of interest are:<LineBreak />
            • Contains: Search within the entire string for the search text<LineBreak />
            • None: No filtering. Return everything in the ItemsSource collection.
            
            <LineBreak />
                    </TextBlock>

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="230" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Padding="5">StartsWith (Default):</TextBlock>

                        <inputToolkit:AutoCompleteBox 
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value3"
                            SelectionChanged="OnSelectionChanged"
                            Width="230" 
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left"
                        />
                        <ContentPresenter Name="Value3" Grid.Column="2" />

                        <TextBlock Padding="5" Grid.Row="1">Contains:</TextBlock>
                        <inputToolkit:AutoCompleteBox 
                            FilterMode="Contains" 
                            MinimumPrefixLength="1" 
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value4"
                            SelectionChanged="OnSelectionChanged"
                            Width="230" 
                            Grid.Row="1"
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left"
                        />
                        <ContentPresenter Name="Value4" Grid.Row="1" Grid.Column="2" />

                        <TextBlock Padding="5" Grid.Row="2">StartsWithCaseSensitive:</TextBlock>

                        <inputToolkit:AutoCompleteBox 
                            FilterMode="StartsWithCaseSensitive"
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value5"
                            SelectionChanged="OnSelectionChanged"
                            Width="230"
                            Grid.Row="2"
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left"
                        />
                        <ContentPresenter Name="Value5" Grid.Row="2" Grid.Column="2" />

                    </Grid>
                </StackPanel>
            </controls:TabItem>

            <controls:TabItem Header="MinimumPopulateDelay">
                <StackPanel>
                    <TextBlock Style="{StaticResource Information}">
            The MinimumPopulateDelay sets the minimum type that must elapse 
            after typing has started and the control waits to filter and find 
            suggestions. Setting this to a higher number than the default (0) 
            will reduce the load on suggestion web services, or complex data 
            filtering. MinimumPopulateDelay has been set to 200ms in this 
            example.
            <LineBreak />
                    </TextBlock>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="230" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Padding="5">Month:</TextBlock>
                        <inputToolkit:AutoCompleteBox 
                            MinimumPopulateDelay="200"
                            Tag="Value6"
                            SelectionChanged="OnSelectionChanged"
                            Grid.Column="1"
                            HorizontalAlignment="Left"
                            Width="230"
                            x:Name="DynamicDelayAutoCompleteBox"
                            >
                            <inputToolkit:AutoCompleteBox.ItemsSource>
                                <toolkit:ObjectCollection>
                                    <system:String>January</system:String>
                                    <system:String>February</system:String>
                                    <system:String>March</system:String>
                                    <system:String>April</system:String>
                                    <system:String>May</system:String>
                                    <system:String>June</system:String>
                                    <system:String>July</system:String>
                                    <system:String>August</system:String>
                                    <system:String>September</system:String>
                                    <system:String>October</system:String>
                                    <system:String>November</system:String>
                                    <system:String>December</system:String>
                                </toolkit:ObjectCollection>
                            </inputToolkit:AutoCompleteBox.ItemsSource>
                        </inputToolkit:AutoCompleteBox>
                        <ContentPresenter Name="Value6" Grid.Column="2" />
                        
                        <TextBlock Padding="5" Grid.Row="1">Minimum Delay:</TextBlock>
                        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="8">
                            <TextBlock>0</TextBlock>
                            <Slider x:Name="SetDelay" Minimum="0" Value="200" SmallChange="50" LargeChange="200" Maximum="1000" Width="200" />
                            <TextBlock>1 second</TextBlock>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </controls:TabItem>

            <controls:TabItem Header="MinimumPrefixLength">
                <StackPanel>
                    <TextBlock Style="{StaticResource Information}">
            The MinimumPrefixLength sets the minimum number of characters that 
            must be typed before suggestions appear.
            
            <LineBreak /><LineBreak />
            
            The default value is 1. In this example, there is a collection of 
            thousands of words. To make more appropriate suggestions, the value 
            of MinimumPrefixLength has been set to 2. For example, search for 
            "th".
            <LineBreak />
                    </TextBlock>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="230" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Padding="5">Word lookup:</TextBlock>
                        <inputToolkit:AutoCompleteBox
                            x:Name="WordComplete" 
                            MinimumPopulateDelay="200"
                            MinimumPrefixLength="2"
                            Tag="Value7"
                            SelectionChanged="OnSelectionChanged"
                            Width="230" 
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left" />
                        <ContentPresenter Name="Value7" Grid.Column="2" />
                        
                        <TextBlock Padding="5" Grid.Row="1">Minimum Length:</TextBlock>
                        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="8">
                            <TextBlock>-1</TextBlock>
                            <Slider x:Name="SetPrefixLength" Minimum="-1" Value="2" Maximum="8" SmallChange="1" LargeChange="2" Width="200" />
                            <TextBlock>8</TextBlock>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </controls:TabItem>
            <controls:TabItem Header="ValueMemberBinding">
                <StackPanel>
                    <TextBlock Style="{StaticResource Information}">
                        The ValueMemberBinding can be used to select the string 
                        value used inside the text box whenever an item is 
                        selected or searched for.
                    </TextBlock>

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="230" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Padding="5" Grid.Row="0">Name:</TextBlock>
                        <inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="False" 
                            Width="230" 
                            Grid.Row="0" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            ValueMemberBinding="{Binding DisplayName}"
                            Tag="Value8"
                            SelectionChanged="OnSelectionChanged"
                        />
                        <ContentPresenter Name="Value8" Grid.Row="0" Grid.Column="2" />
                        
                        <TextBlock Padding="5" Grid.Row="1">First name:</TextBlock>
                        <inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="False" 
                            Width="230" 
                            Grid.Row="1" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            ValueMemberBinding="{Binding FirstName}"
                            Tag="Value9"
                            SelectionChanged="OnSelectionChanged"
                        />
                        <ContentPresenter Name="Value9" Grid.Row="1" Grid.Column="2" />
                    </Grid>
                </StackPanel>
            </controls:TabItem>
        </controls:TabControl>

        <src:SourceViewer xmlns:src="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="AutoCompleteBoxSample.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;

&lt;UserControl x:Class="System.Windows.Controls.Samples.AutoCompleteBoxSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:samples="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    &gt;
    &lt;UserControl.Resources&gt;
        &lt;samples:SampleEmployeeCollection x:Key="SampleEmployees" /&gt;
    &lt;/UserControl.Resources&gt;

    &lt;StackPanel&gt;

        &lt;ContentControl Content="AutoCompleteBox" Style="{StaticResource Header}" /&gt;
        &lt;TextBlock Style="{StaticResource Information}"&gt;
            AutoCompleteBox is a control that provides suggested items for a 
            TextBox. It can be bound to rich data objects, exposes a 
            SelectedItem property, and is highly customizable and extensible.
            
            &lt;LineBreak /&gt;&lt;LineBreak /&gt;
            
            The following sections cover key properties and settings that 
            customize the way that AutoCompleteBox behaves.
            &lt;LineBreak /&gt;
        &lt;/TextBlock&gt;

        &lt;controls:TabControl&gt;
            &lt;controls:TabItem Header="IsTextCompletionEnabled"&gt;
                &lt;StackPanel&gt;
                    &lt;TextBlock Style="{StaticResource Information}"&gt;
                        IsTextCompletionEnabled will automatically select the 
                        best matching suggestion when one becomes available. The
                        text will be automatically completed for you. 
                        IsTextCompletionEnabled is set to False by default.
                    &lt;/TextBlock&gt;

                    &lt;Grid&gt;
                        &lt;Grid.ColumnDefinitions&gt;
                            &lt;ColumnDefinition Width="230" /&gt;
                            &lt;ColumnDefinition Width="250" /&gt;
                            &lt;ColumnDefinition /&gt;
                        &lt;/Grid.ColumnDefinitions&gt;
                        &lt;Grid.RowDefinitions&gt;
                            &lt;RowDefinition /&gt;
                            &lt;RowDefinition /&gt;
                        &lt;/Grid.RowDefinitions&gt;

                        &lt;TextBlock Padding="5" Grid.Row="0"&gt;Default:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="False" 
                            Width="230" 
                            Grid.Row="0" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value1"
                            SelectionChanged="OnSelectionChanged"
                        /&gt;
                        &lt;ContentPresenter Name="Value1" Grid.Row="0" Grid.Column="2" /&gt;

                        &lt;TextBlock Padding="5" Grid.Row="1"&gt;IsTextCompletionEnabled:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="True"
                            Width="230" 
                            Grid.Row="1" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value2"
                            SelectionChanged="OnSelectionChanged"
                        /&gt;
                        &lt;ContentPresenter Grid.Row="1" Name="Value2" Grid.Column="2" /&gt;

                    &lt;/Grid&gt;
                &lt;/StackPanel&gt;
            &lt;/controls:TabItem&gt;
            &lt;controls:TabItem Header="FilterMode"&gt;
                &lt;StackPanel&gt;
                    &lt;TextBlock Style="{StaticResource Information}"&gt;
            FilterMode makes it easy to customize the search filter that is 
            used on the text. The default value is StartsWith: a case-insensitive 
            search filter that compares the start of strings.
            
            &lt;LineBreak /&gt;&lt;LineBreak /&gt;
            
            Other FilterMode values of interest are:&lt;LineBreak /&gt;
            • Contains: Search within the entire string for the search text&lt;LineBreak /&gt;
            • None: No filtering. Return everything in the ItemsSource collection.
            
            &lt;LineBreak /&gt;
                    &lt;/TextBlock&gt;

                    &lt;Grid&gt;
                        &lt;Grid.ColumnDefinitions&gt;
                            &lt;ColumnDefinition Width="230" /&gt;
                            &lt;ColumnDefinition Width="250" /&gt;
                            &lt;ColumnDefinition /&gt;
                        &lt;/Grid.ColumnDefinitions&gt;
                        &lt;Grid.RowDefinitions&gt;
                            &lt;RowDefinition /&gt;
                            &lt;RowDefinition /&gt;
                            &lt;RowDefinition /&gt;
                        &lt;/Grid.RowDefinitions&gt;

                        &lt;TextBlock Padding="5"&gt;StartsWith (Default):&lt;/TextBlock&gt;

                        &lt;inputToolkit:AutoCompleteBox 
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value3"
                            SelectionChanged="OnSelectionChanged"
                            Width="230" 
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left"
                        /&gt;
                        &lt;ContentPresenter Name="Value3" Grid.Column="2" /&gt;

                        &lt;TextBlock Padding="5" Grid.Row="1"&gt;Contains:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox 
                            FilterMode="Contains" 
                            MinimumPrefixLength="1" 
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value4"
                            SelectionChanged="OnSelectionChanged"
                            Width="230" 
                            Grid.Row="1"
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left"
                        /&gt;
                        &lt;ContentPresenter Name="Value4" Grid.Row="1" Grid.Column="2" /&gt;

                        &lt;TextBlock Padding="5" Grid.Row="2"&gt;StartsWithCaseSensitive:&lt;/TextBlock&gt;

                        &lt;inputToolkit:AutoCompleteBox 
                            FilterMode="StartsWithCaseSensitive"
                            ItemsSource="{StaticResource SampleEmployees}"
                            Tag="Value5"
                            SelectionChanged="OnSelectionChanged"
                            Width="230"
                            Grid.Row="2"
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left"
                        /&gt;
                        &lt;ContentPresenter Name="Value5" Grid.Row="2" Grid.Column="2" /&gt;

                    &lt;/Grid&gt;
                &lt;/StackPanel&gt;
            &lt;/controls:TabItem&gt;

            &lt;controls:TabItem Header="MinimumPopulateDelay"&gt;
                &lt;StackPanel&gt;
                    &lt;TextBlock Style="{StaticResource Information}"&gt;
            The MinimumPopulateDelay sets the minimum type that must elapse 
            after typing has started and the control waits to filter and find 
            suggestions. Setting this to a higher number than the default (0) 
            will reduce the load on suggestion web services, or complex data 
            filtering. MinimumPopulateDelay has been set to 200ms in this 
            example.
            &lt;LineBreak /&gt;
                    &lt;/TextBlock&gt;
                    &lt;Grid&gt;
                        &lt;Grid.ColumnDefinitions&gt;
                            &lt;ColumnDefinition Width="230" /&gt;
                            &lt;ColumnDefinition Width="250" /&gt;
                            &lt;ColumnDefinition /&gt;
                        &lt;/Grid.ColumnDefinitions&gt;
                        &lt;Grid.RowDefinitions&gt;
                            &lt;RowDefinition /&gt;
                            &lt;RowDefinition /&gt;
                        &lt;/Grid.RowDefinitions&gt;
                        &lt;TextBlock Padding="5"&gt;Month:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox 
                            MinimumPopulateDelay="200"
                            Tag="Value6"
                            SelectionChanged="OnSelectionChanged"
                            Grid.Column="1"
                            HorizontalAlignment="Left"
                            Width="230"
                            x:Name="DynamicDelayAutoCompleteBox"
                            &gt;
                            &lt;inputToolkit:AutoCompleteBox.ItemsSource&gt;
                                &lt;toolkit:ObjectCollection&gt;
                                    &lt;system:String&gt;January&lt;/system:String&gt;
                                    &lt;system:String&gt;February&lt;/system:String&gt;
                                    &lt;system:String&gt;March&lt;/system:String&gt;
                                    &lt;system:String&gt;April&lt;/system:String&gt;
                                    &lt;system:String&gt;May&lt;/system:String&gt;
                                    &lt;system:String&gt;June&lt;/system:String&gt;
                                    &lt;system:String&gt;July&lt;/system:String&gt;
                                    &lt;system:String&gt;August&lt;/system:String&gt;
                                    &lt;system:String&gt;September&lt;/system:String&gt;
                                    &lt;system:String&gt;October&lt;/system:String&gt;
                                    &lt;system:String&gt;November&lt;/system:String&gt;
                                    &lt;system:String&gt;December&lt;/system:String&gt;
                                &lt;/toolkit:ObjectCollection&gt;
                            &lt;/inputToolkit:AutoCompleteBox.ItemsSource&gt;
                        &lt;/inputToolkit:AutoCompleteBox&gt;
                        &lt;ContentPresenter Name="Value6" Grid.Column="2" /&gt;
                        
                        &lt;TextBlock Padding="5" Grid.Row="1"&gt;Minimum Delay:&lt;/TextBlock&gt;
                        &lt;StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="8"&gt;
                            &lt;TextBlock&gt;0&lt;/TextBlock&gt;
                            &lt;Slider x:Name="SetDelay" Minimum="0" Value="200" SmallChange="50" LargeChange="200" Maximum="1000" Width="200" /&gt;
                            &lt;TextBlock&gt;1 second&lt;/TextBlock&gt;
                        &lt;/StackPanel&gt;
                    &lt;/Grid&gt;
                &lt;/StackPanel&gt;
            &lt;/controls:TabItem&gt;

            &lt;controls:TabItem Header="MinimumPrefixLength"&gt;
                &lt;StackPanel&gt;
                    &lt;TextBlock Style="{StaticResource Information}"&gt;
            The MinimumPrefixLength sets the minimum number of characters that 
            must be typed before suggestions appear.
            
            &lt;LineBreak /&gt;&lt;LineBreak /&gt;
            
            The default value is 1. In this example, there is a collection of 
            thousands of words. To make more appropriate suggestions, the value 
            of MinimumPrefixLength has been set to 2. For example, search for 
            "th".
            &lt;LineBreak /&gt;
                    &lt;/TextBlock&gt;
                    &lt;Grid&gt;
                        &lt;Grid.ColumnDefinitions&gt;
                            &lt;ColumnDefinition Width="230" /&gt;
                            &lt;ColumnDefinition Width="250" /&gt;
                            &lt;ColumnDefinition /&gt;
                        &lt;/Grid.ColumnDefinitions&gt;
                        &lt;Grid.RowDefinitions&gt;
                            &lt;RowDefinition /&gt;
                            &lt;RowDefinition /&gt;
                        &lt;/Grid.RowDefinitions&gt;
                        &lt;TextBlock Padding="5"&gt;Word lookup:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox
                            x:Name="WordComplete" 
                            MinimumPopulateDelay="200"
                            MinimumPrefixLength="2"
                            Tag="Value7"
                            SelectionChanged="OnSelectionChanged"
                            Width="230" 
                            Grid.Column="1"
                            Margin="0, 8, 0, 8"
                            HorizontalAlignment="Left" /&gt;
                        &lt;ContentPresenter Name="Value7" Grid.Column="2" /&gt;
                        
                        &lt;TextBlock Padding="5" Grid.Row="1"&gt;Minimum Length:&lt;/TextBlock&gt;
                        &lt;StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="8"&gt;
                            &lt;TextBlock&gt;-1&lt;/TextBlock&gt;
                            &lt;Slider x:Name="SetPrefixLength" Minimum="-1" Value="2" Maximum="8" SmallChange="1" LargeChange="2" Width="200" /&gt;
                            &lt;TextBlock&gt;8&lt;/TextBlock&gt;
                        &lt;/StackPanel&gt;
                    &lt;/Grid&gt;
                &lt;/StackPanel&gt;
            &lt;/controls:TabItem&gt;
            &lt;controls:TabItem Header="ValueMemberBinding"&gt;
                &lt;StackPanel&gt;
                    &lt;TextBlock Style="{StaticResource Information}"&gt;
                        The ValueMemberBinding can be used to select the string 
                        value used inside the text box whenever an item is 
                        selected or searched for.
                    &lt;/TextBlock&gt;

                    &lt;Grid&gt;
                        &lt;Grid.ColumnDefinitions&gt;
                            &lt;ColumnDefinition Width="230" /&gt;
                            &lt;ColumnDefinition Width="250" /&gt;
                            &lt;ColumnDefinition /&gt;
                        &lt;/Grid.ColumnDefinitions&gt;
                        &lt;Grid.RowDefinitions&gt;
                            &lt;RowDefinition /&gt;
                            &lt;RowDefinition /&gt;
                        &lt;/Grid.RowDefinitions&gt;

                        &lt;TextBlock Padding="5" Grid.Row="0"&gt;Name:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="False" 
                            Width="230" 
                            Grid.Row="0" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            ValueMemberBinding="{Binding DisplayName}"
                            Tag="Value8"
                            SelectionChanged="OnSelectionChanged"
                        /&gt;
                        &lt;ContentPresenter Name="Value8" Grid.Row="0" Grid.Column="2" /&gt;
                        
                        &lt;TextBlock Padding="5" Grid.Row="1"&gt;First name:&lt;/TextBlock&gt;
                        &lt;inputToolkit:AutoCompleteBox 
                            IsTextCompletionEnabled="False" 
                            Width="230" 
                            Grid.Row="1" Grid.Column="1" Margin="0, 8, 0, 8" HorizontalAlignment="Left"
                            ItemsSource="{StaticResource SampleEmployees}"
                            ValueMemberBinding="{Binding FirstName}"
                            Tag="Value9"
                            SelectionChanged="OnSelectionChanged"
                        /&gt;
                        &lt;ContentPresenter Name="Value9" Grid.Row="1" Grid.Column="2" /&gt;
                    &lt;/Grid&gt;
                &lt;/StackPanel&gt;
            &lt;/controls:TabItem&gt;
        &lt;/controls:TabControl&gt;
    &lt;/StackPanel&gt;
&lt;/UserControl&gt;
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="AutoCompleteBoxSample.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;

// Global suppressions for this sample
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value1")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value2")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value3")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value4")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value5")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value6")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value7")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value8")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value9")]

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// The AutoCompleteGettingStarted sample page shows several common uses 
    /// of the AutoCompleteBox control.
    /// &lt;/summary&gt;
    [Sample("(0)AutoCompleteBox", DifficultyLevel.Basic)]
    [Category("AutoCompleteBox")]
    public partial class AutoCompleteBoxSample : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the AutoCompleteGettingStarted class.
        /// &lt;/summary&gt;
        public AutoCompleteBoxSample()
        {
            InitializeComponent();
            Loaded += OnLoaded;
        }

        /// &lt;summary&gt;
        /// Hook up to the Loaded event.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source object.&lt;/param&gt;
        /// &lt;param name="e"&gt;The event data.&lt;/param&gt;
        private void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            // Words
            WordComplete.ItemsSource = Words.GetAliceInWonderland();

            // Sliders
            SetDelay.ValueChanged += (s, args) =&gt; DynamicDelayAutoCompleteBox.MinimumPopulateDelay = (int)Math.Floor(SetDelay.Value);
            SetPrefixLength.ValueChanged += (s, args) =&gt; WordComplete.MinimumPrefixLength = (int)Math.Floor(SetPrefixLength.Value);
        }

        /// &lt;summary&gt;
        /// Called when an AutoCompleteBox's selected value changes. Uses the 
        /// Tag property to identify the content presenter to be updated.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source AutoCompleteBox control.&lt;/param&gt;
        /// &lt;param name="e"&gt;The event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Event is wired up in XAML.")]
        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            AutoCompleteBox acb = (AutoCompleteBox)sender;

            // In these sample scenarios, the Tag is the name of the content 
            // presenter to use to display the value.
            string contentPresenterName = (string)acb.Tag;
            ContentPresenter cp = FindName(contentPresenterName) as ContentPresenter;
            if (cp != null)
            {
                cp.Content = acb.SelectedItem;
            }
        }
    }
}</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="AutoCompleteBoxSample.xaml.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports Microsoft.VisualBasic
Imports System
Imports System.Diagnostics.CodeAnalysis
Imports System.Windows
Imports System.Windows.Controls
Imports System.ComponentModel

' Global suppressions for this sample
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value1")&gt;
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value2")&gt;
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value3")&gt;
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value4")&gt;
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value5")&gt;
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value6")&gt;
&lt;Assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope := "member", Target := "System.Windows.Controls.Samples.AutoCompleteBoxSample.#Value7")&gt;

''' &lt;summary&gt;
''' The AutoCompleteGettingStarted sample page shows several common uses 
''' of the AutoCompleteBox control.
''' &lt;/summary&gt;
&lt;Sample("(0)AutoCompleteBox", DifficultyLevel.Basic), Category("AutoCompleteBox")&gt; _
Partial Public Class AutoCompleteBoxSample
    Inherits UserControl
    ''' &lt;summary&gt;
    ''' Initializes a new instance of the AutoCompleteGettingStarted class.
    ''' &lt;/summary&gt;
    Public Sub New()
        InitializeComponent()
    End Sub

    ''' &lt;summary&gt;
    ''' Hook up to the Loaded event.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The source object.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The event data.&lt;/param&gt;
    Private Sub OnLoaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        ' Words
        WordComplete.ItemsSource = Words.GetAliceInWonderland()

        ' Sliders
        AddHandler SetDelay.ValueChanged, Function(s, args) DynamicDelayAutoCompleteBox.MinimumPopulateDelay = CInt(Fix(Math.Floor(SetDelay.Value)))
        AddHandler SetPrefixLength.ValueChanged, Function(s, args) WordComplete.MinimumPrefixLength = CInt(Fix(Math.Floor(SetPrefixLength.Value)))
    End Sub

    ''' &lt;summary&gt;
    ''' Called when an AutoCompleteBox's selected value changes. Uses the 
    ''' Tag property to identify the content presenter to be updated.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The source AutoCompleteBox control.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The event data.&lt;/param&gt;
    &lt;SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Event is wired up in XAML.")&gt; _
    Private Sub OnSelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim acb As AutoCompleteBox = CType(sender, AutoCompleteBox)

        ' In these sample scenarios, the Tag is the name of the content 
        ' presenter to use to display the value.
        Dim contentPresenterName As String = CStr(acb.Tag)
        Dim cp As ContentPresenter = TryCast(FindName(contentPresenterName), ContentPresenter)
        If cp IsNot Nothing Then
            cp.Content = acb.SelectedItem
        End If
    End Sub
End Class
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="SampleEmployeeCollection.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Collections;
using System.Windows.Controls;

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// A collection type that makes it easy to place sample employee data into 
    /// XAML.
    /// &lt;/summary&gt;
    public class SampleEmployeeCollection : ObjectCollection
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the SampleEmployeeCollection class.
        /// &lt;/summary&gt;
        public SampleEmployeeCollection()
            : base(Employee.AllExecutives)
        {
        }
    }
}</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="SampleEmployeeCollection.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Windows.Controls

''' &lt;summary&gt;
''' A collection type that makes it easy to place sample employee data into 
''' XAML.
''' &lt;/summary&gt;
Public Class SampleEmployeeCollection
    Inherits ObjectCollection
    ''' &lt;summary&gt;
    ''' Initializes a new instance of the SampleEmployeeCollection class.
    ''' &lt;/summary&gt;
    Public Sub New()
        MyBase.New(Employee.AllExecutives)
    End Sub
End Class
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
    </StackPanel>
</UserControl>
